import { readFile, readFileSync } from "fs";
import Channel from "./channel/channel";

let channel = new Channel(8, false, false, {
    host: "host",
    port: 10000
}, () => {
    console.log("channel ready");
});

//let file:Buffer = readFileSync("./1.flv");
let buffer:Buffer = Buffer.alloc(1024*1024*10);
channel.regChannelAllConnected(() => {
    setTimeout(() => {
        channel.sendData(buffer, 10000);
        channel.sendData(buffer, 10001);
        channel.sendData(buffer, 10002);
        channel.sendData(buffer, 10003);
        channel.sendData(buffer, 10004);
    }, 5000);
    console.log("5秒后开始传输文件");
});

function a() {
    setTimeout(() => {
        b();
    }, 500);
}
function b() {
    setTimeout(() => {
        a();
    }, 500);
}